package com.dtwave.utils;

import com.dtwave.constant.FieldConstants;

/***
 * 字符串工具类
 */
public class StrUtils {

    public static String subStr(String str, Integer start, Integer length) {

        String substring = "";
        if (str != null && start != null && length != null
                && start > 0 && length > 0
                && str.length() >= (start + length - 1)) {
            substring = str.substring(start - 1, start + length - 1);
        }
        if (substring != null) {
            substring = substring.trim();
        }
        return substring;
    }

    public static String trim(String str) {
        if (str == null) {
            return "";
        }
        str = str.trim();
        if (FieldConstants.NULL.equals(str)) {
            return "";
        }
        return str;
    }

}
